package com.demo2do.boyle.common.entity.aduser.transaction;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.demo2do.boyle.common.entity.aduser.Aduser;
import com.demo2do.boyle.common.entity.aduser.order.PayType;

/**
 * 
 * @author downpour leo
 */
@Entity
@Table( name = "aduser_transaction")
public class AduserTransaction {
	
	@Id
	@GeneratedValue
	private Integer id;
	
	@ManyToOne(optional = true, fetch = FetchType.LAZY)
	private Aduser aduser;
	
	@Enumerated(EnumType.ORDINAL)
	@Column(name = "type")
	private TransactionType transactionType;
	
	private Date createTime;
	
	private int balance;
	
	private Integer businessId;
	
	@Enumerated(EnumType.ORDINAL)
    private PayType payType;
	
	@Column(name = "is_deleted")
	private boolean disabled;
	
	/**
	 * The default constructor
	 */
	public AduserTransaction() {
		
	}
	
	/**
	 * The constructor using fields
	 * 
	 * @param aduser
	 * @param transactionType
	 * @param payType
	 */
	public AduserTransaction(Aduser aduser, TransactionType transactionType, PayType payType) {
		this.aduser = aduser;
		this.transactionType = transactionType;
		this.payType = payType;
		this.createTime = new Date();
	}
	
	/**
	 * Initialize with balance
	 * 
	 * @param balance
	 * @return
	 */
	public AduserTransaction initialize(int balance) {
		this.balance = balance;
		this.disabled = false;
		return this;
	}
	
	/**
	 * Initialize with balance and businessId
	 * 
	 * @param balance
	 * @param businessId
	 * @return
	 */
	public AduserTransaction initialize(int balance, Integer businessId) {
		this.balance = balance;
		this.businessId = businessId;
		this.disabled = false;
		return this;
	}

	/**
	 * @return the id
	 */
	public Integer getId() {
		return id;
	}

	/**
	 * @return the aduser
	 */
	public Aduser getAduser() {
		return aduser;
	}

	/**
	 * @return the transactionType
	 */
	public TransactionType getTransactionType() {
		return transactionType;
	}

	/**
	 * @return the createTime
	 */
	public Date getCreateTime() {
		return createTime;
	}

	/**
	 * @return the balance
	 */
	public int getBalance() {
		return balance;
	}

	/**
	 * @return the businessId
	 */
	public Integer getBusinessId() {
		return businessId;
	}

	/**
	 * @return the payType
	 */
	public PayType getPayType() {
		return payType;
	}

	/**
	 * @return the disabled
	 */
	public boolean isDisabled() {
		return disabled;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * @param aduser the aduser to set
	 */
	public void setAduser(Aduser aduser) {
		this.aduser = aduser;
	}

	/**
	 * @param transactionType the transactionType to set
	 */
	public void setTransactionType(TransactionType transactionType) {
		this.transactionType = transactionType;
	}

	/**
	 * @param createTime the createTime to set
	 */
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	/**
	 * @param balance the balance to set
	 */
	public void setBalance(int balance) {
		this.balance = balance;
	}

	/**
	 * @param businessId the businessId to set
	 */
	public void setBusinessId(Integer businessId) {
		this.businessId = businessId;
	}

	/**
	 * @param payType the payType to set
	 */
	public void setPayType(PayType payType) {
		this.payType = payType;
	}

	/**
	 * @param disabled the disabled to set
	 */
	public void setDisabled(boolean disabled) {
		this.disabled = disabled;
	}
	
}

